/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class CartModifyResponse
    {
    
        private  OperationRequest operationRequestField;
        private  List<Cart> cartField;


        /// <summary>
        /// Gets and sets the OperationRequest property.
        /// </summary>
        [XmlElementAttribute(ElementName = "OperationRequest")]
        public OperationRequest OperationRequest
        {
            get { return this.operationRequestField ; }
            set { this.operationRequestField = value; }
        }



        /// <summary>
        /// Sets the OperationRequest property
        /// </summary>
        /// <param name="operationRequest">OperationRequest property</param>
        /// <returns>this instance</returns>
        public CartModifyResponse WithOperationRequest(OperationRequest operationRequest)
        {
            this.operationRequestField = operationRequest;
            return this;
        }



        /// <summary>
        /// Checks if OperationRequest property is set
        /// </summary>
        /// <returns>true if OperationRequest property is set</returns>
        public Boolean IsSetOperationRequest()
        {
            return this.operationRequestField != null;
        }




        /// <summary>
        /// Gets and sets the Cart property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Cart")]
        public List<Cart> Cart
        {
            get
            {
                if (this.cartField == null)
                {
                    this.cartField = new List<Cart>();
                }
                return this.cartField;
            }
            set { this.cartField =  value; }
        }



        /// <summary>
        /// Sets the Cart property
        /// </summary>
        /// <param name="list">Cart property</param>
        /// <returns>this instance</returns>
        public CartModifyResponse WithCart(params Cart[] list)
        {
            foreach (Cart item in list)
            {
                Cart.Add(item);
            }
            return this;
        }          
 


        /// <summary>
        /// Checks if Cart property is set
        /// </summary>
        /// <returns>true if Cart property is set</returns>
        public Boolean IsSetCart()
        {
            return (Cart.Count > 0);
        }




        /// <summary>
        /// XML Representation for this object
        /// </summary>
        /// <returns>XML String</returns>

        public String ToXML() {
            StringBuilder xml = new StringBuilder();
            xml.Append("<CartModifyResponse xmlns=\"http://webservices.amazon.com/AWSECommerceService/2007-07-16\">");
            if (IsSetOperationRequest()) {
                OperationRequest  operationRequest = this.OperationRequest;
                xml.Append("<OperationRequest>");
                xml.Append(operationRequest.ToXMLFragment());
                xml.Append("</OperationRequest>");
            } 
            List<Cart> cartList = this.Cart;
            foreach (Cart cart in cartList) {
                xml.Append("<Cart>");
                xml.Append(cart.ToXMLFragment());
                xml.Append("</Cart>");
            }
            xml.Append("</CartModifyResponse>");
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}